// import { baseUrl } from '@/config'
let httpApi = 'https://m.lnzld.com'
// 微信授权相关配置
const wxConfig = {
  appId: 'wx43a8af4d81c817ba', // 公众号的appid
  scope: 'snsapi_base', // 静默授权
  redirectUri: encodeURIComponent(`${httpApi}/pages/users/pay_page/index`) // 回调页面
}

// 获取微信授权URL
export const getWxAuthUrl = (state = '') => {
  return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${wxConfig.appId}&redirect_uri=${wxConfig.redirectUri}&response_type=code&scope=${wxConfig.scope}&state=${state}#wechat_redirect`
}

// 检查登录状态
export const checkLogin = () => {
  const token = uni.getStorageSync('token')
  return !!token
}

// 保存登录信息
export const saveLoginInfo = (data) => {
  const { token, userInfo } = data
  uni.setStorageSync('token', token)
  uni.setStorageSync('userInfo', userInfo)
}

// 清除登录信息
export const clearLoginInfo = () => {
  uni.removeStorageSync('token')
  uni.removeStorageSync('userInfo')
}